{extend name="public/layout" /}
{block name="body"}
    <form class="layui-form" > <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        <div class="layui-card pd-bt-15">
            <div class="layui-row">
                <div class="layui-col-md8">
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.title}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-row">
                <div class="layui-col-md8">
                    <div class="layui-form-item">
                        <label class="layui-form-label">类别</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.engineeringType.name}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-row">
                <div class="layui-col-md8">
                    <div class="layui-form-item">
                        <label class="layui-form-label">详情</label>
                        <div class="layui-input-block">
                            <textarea type="text" readonly class="layui-textarea">{$vo.detail}</textarea>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-row">
                <div class="layui-col-md3">
                    <div class="layui-form-item">
                        <label class="layui-form-label">联系人</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.contacts}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md3">
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机号码</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.mobile}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md2">
                    <div class="layui-form-item">
                        <label class="layui-form-label">发布人</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.uid}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
            </div>




            <div class="layui-row">
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label">更新时间</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.update_time}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label">添加时间</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.add_time}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-row">
                <div class="layui-col-md2">
                    <div class="layui-form-item">
                        <label class="layui-form-label">审核状态</label>
                        <div class="layui-input-block">
                            <input  data-id="{$vo.id}" lay-filter="update_status"  type="checkbox" lay-skin="switch" {if condition="$vo.status eq 1"}checked{/if} lay-text="通过|失败">
                        </div>
                    </div>
                </div>

                <div class="layui-col-md2">
                    <div class="layui-form-item">
                        <label class="layui-form-label">浏览人数</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.pv}" readonly class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-col-md2">
                    <div class="layui-form-item">
                        <label class="layui-form-label">点赞数</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.like_num}" readonly class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-col-md2">
                    <div class="layui-form-item">
                        <label class="layui-form-label">评论数</label>
                        <div class="layui-input-block">
                            <input type="text" value="{$vo.comment_num}" readonly class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-row">
                <div class="layui-col-md8">
                    <div class="layui-form-item">
                        <label class="layui-form-label">图片集</label>
                        <div class="layui-input-block">
                            {foreach name='vo.imgs' item='img'}
                                <img width="200" src="{$img.path}">
                            {/foreach}
                        </div>
                    </div>
                </div>
            </div>

            <input type="hidden" name="id" value="{$vo.id}"/>
        </div>
    </form>
{/block}

{block name="script"}
    <script>
        layui.use(['form'], function() {
            var form = layui.form;
            $ = layui.$;
            form.on('switch(update_status)', function (data) {
                var now = $(this).prop('checked');
                var url = "{:url('update_status')}";
                var d = new Object();
                var _this = this;
                d.id = $(this).attr('data-id');
                if (now) {
                    d.status = 1;
                } else {
                    d.status = 0;

                }
                $.post(url, d, function (data) {
                    if (data.code != 10000) {
                        if (now) {
                            $(_this).removeAttr('checked');
                        } else {
                            $(_this).attr('checked', true);

                        }
                        layer.msg(data.msg,{icon:2,time:1500})
                    }
                    form.render('checkbox');
                });

            });
        });
    </script>
{/block}